package fox.framework.rpc.client.node;

import fox.framework.rpc.endpoint.channel.RpcChannel;

/**
 * RPC注册节点基类
 * @author cuichao
 * @Description: RpcNode
 * @Date: create in 2020/12/16 16:00
 */
public abstract class RpcNode {
    /**
     * 运行状态 已经和远程RpcNode连接上了
     */
    public static final int RPC_NODE_RUNNING = -1;
    /**
     * 准备状态 已经从注册中心获取数据(初始化、重新上线),但客户端还未连接
     */
    public static final int RPC_NODE_READY = 0;
    /***
     * 暂停阶段 客户端的连接已经断开,注册中心还未通知下线
     */
    public static final int RPC_NODE_PAUSE = 1;
    /**
     * 下线阶段 注册中心已通知其下线
     */
    public static final int RPC_NODE_SHUTDOWN = 2;

    private volatile int state = RPC_NODE_READY;
    /**
     * 节点ip地址
     */
    protected String host;
    /**
     * 节点端口号
     */
    protected int port;
    /**
     *节点路径 node/group
     */
    protected Object path;
    /**
     * 节点网络地址
     */
    protected String address;
    /**
     * Rpc所属channel
     */
    private RpcChannel channel;


    public void setState(int state){
        this.state = state;
    }


    public void setChannel(RpcChannel channel){
        this.channel = channel;
    }

    public int getState() {
        return state;
    }

    public Object getPath() {
        return path;
    }

    public String getAddress() {
        return address;
    }

    public RpcChannel getChannel() {
        return channel;
    }

    public String getHost() {
        return host;
    }

    public int getPort() {
        return port;
    }
}
